

import alias from 'rollup-plugin-alias'
import commonjs from "rollup-plugin-commonjs";    //将CommonJS模块转换成ES6，防止他们在Rollup中失效;

const { join } = require('path')
const resolve = require('rollup-plugin-node-resolve')
const rollup=require('rollup')

const babel = require('rollup-plugin-babel')
const cwd = __dirname


// rollup.rollup({
//   entry:require('./app/jim/index.js'),
//   plugins:[
//     alias({
//       'jim':join(cwd,'app/jim'),
//       'src':join(cwd,'app/src'),
//       'utils':join(cwd,'app/utils'),
//     }),
//     resolve({
//       preferBuiltins: false,
//     }),  
//   babel({
//     babelrc:true,
//     runtimeHelpers: true ,
//     exclude: 'node_modules/**'
//   })],
// }).then(function(bundle){
//   bundle.write({
//     format:'umd',
//     moduleName:'jim', //umd或iife模式下，如入口文件含export，必须加上该属性
//     dest:'bundle.js',
//   })
// })

export default {
  input:'./app/utils/websocket.js',
  output:{
    format:'iife',
    file:'dist/websocket.js',
  },
  plugins:[
    commonjs(),           //将CommonJS模块转换成ES6;
    alias({
      'jim':join(cwd,'app/jim'),
      'src':join(cwd,'app/src'),
      'utils':join(cwd,'app/utils'),
    }),
    resolve({
      preferBuiltins: false,
    }),  
  babel({
    babelrc:false,
    presets: ['es2015-rollup', 'stage-0'], //转ES5的插件;
    plugins: ['transform-class-properties'],//转换静态类属性以及属性声明的属性初始化语法
    exclude: 'node_modules/**'
  })],

}


